package Thread;

public class ThreadDemo18 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            for (int i = 0; i < 1000; i++) {
                System.out.println("线程运行中……");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        //线程启动之前就是NEW状态
        System.out.println(thread.getState());
        thread.start();
        Thread.sleep(500);
        //此时线程仍在sleep
        System.out.println(thread.getState());
        thread.join();
        //线程运行结束后状态就是TERMINATED
        System.out.println(thread.getState());
    }
}
